package com.Nuyoah.demo01.mappers;

import com.Nuyoah.demo01.entity.Rank;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface RankMapper {
    //从score表按分数从大到小查询，利用score表中的user_id关联users表，获取用户名username,返回Rank对象
    @Select("SELECT score.*, users.username,RANK() OVER (ORDER BY score.score DESC) as rank_user\n" +
            "FROM score\n" +
            "LEFT JOIN users ON score.user_id = users.user_id\n" +
            "ORDER BY score.score DESC;")
    List<Rank> getRank();
}
